Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

feature: Add preview from gphoto #131

Merged
merged 9 commits into from
Nov 17, 2020
Merged

feature: Add preview from gphoto #131

merged 9 commits into from
Nov 17, 2020

Conversation

andi34
Copy link
Owner

@andi34 andi34 commented Nov 8, 2020

Prerequisites checklist

What is the purpose of this pull request? (put an "x" next to an item)

  • New feature

What changes did you make? (Give an overview)

Changes adapted from couz74@4b5ba4c for latest Photobooth source, adjustments added to not conflict with other preview mode options.
Closes #83

  • install dependencies sudo apt install ffmpeg v4l2loopback-dkms -y
  • create the virtual webcam modprobe v4l2loopback exclusive_caps=1 card_label="GPhoto2 Webcam"
    • /dev/video0 is used by default, you can use v42l-ctl --list-devices to check which /dev/* is the correct one
  • Give permissions to /dev/video* sudo gpasswd -a www-data video
  • reboot once
  • In the admin panel set preview mode to from gphoto
Troubleshooting
  • For Installation Problems on v4l2loopback-dkms Just see the issue here

  • Issue with Chromium (did not test firefox), if there is another webcam like
    bcm2835-isp in my side it take it by default instead of the Gphoto one... therefore I always do rmmod bcm2835-isp

  • Chromium sometimes doesn't detect the Gphoto webcam if it wasn't loaded first with a Gphoto Webcam having the Ffmjpg feed. To do that I send the command in a shell sudo gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 then I start Chromium and check if a testing webcam website work ( https://www.aaronbenjamin.design/camera-app/part-2/ or https://www.onlinemictest.com/webcam-test/ for example)

Conversation on andreknieriem#242:

For it to work on startup I had to edit /etc/rc.local:
modprobe v4l2loopback exclusive_caps=1 card_label="GPhoto2 Webcam"
rmmod bcm2835-isp

rmmod bcm2835-isp was needed as chromium was taking this device instead of the V4l2 one.

How it work
We use v4l2loopback to create a virtual device and gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 to send the photo preview to it.
On "take pic" button we start the process and end to before the picture is taken to free gphoto2.

It is a ugly draft, I hope I will improve it and post the update here.

There is still two issue:

  • Sometime I need to run sudo gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 first and load chrome a first time with a webpage asking for the camera. If I don't do so sometime chrome doesn't detect the V4l2 camera launch from php.
  • On the takeVideo.php I need to use a sleep() method in order to allow the stream to launch, still need to figure a way to have something cleaner

Hi,
In the admin panel the setting "See preview by device cam" must indeed be set.
Then there are three things:

  • modprobe v4l2loopback exclusive_caps=1 card_label="GPhoto2 Webcam" create the virtual webcam and sudo gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 in the takeVideo.php send the outpout of the Gphoto command to the /dev/video0 device (you can use v42l-ctl --list-devices to check which /dev/* is the correct one).
  • The second thing is the issue with Chromium (did not test firefox), if there is another webcam like
    bcm2835-isp in my side it take it by default instead of the Gphoto one... therefore I always do rmmod bcm2835-isp.
  • Finaly Chromium sometimes also doesn't detect the Gphoto webcam if it wasn't loaded first with a Gphoto Webcam having the Ffmjpg feed . To do that I send the command in a shell sudo gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 then I start Chromium and check if a testing webcam website work.

As you can see there is still some issue with the solution XD

Is there anything you'd like reviewers to focus on?

@andi34 andi34 force-pushed the feature/gphoto-preview2 branch 4 times, most recently from 1bdaf5c to e9032a1 Compare November 14, 2020 10:38
couz74 and others added 2 commits November 14, 2020 11:56
Change-Id: Idd63d19ca60913bf5dc89f3d7ed17eacfa9545e8
Change-Id: Id2d48621529cea2733c64102658c1d47ef5a7cda
@andi34 andi34 mentioned this pull request Nov 14, 2020
Change-Id: Ie2869b7e1ad3f442ad8c4a37c11174988c31f93e
- a small delay is needed to use gphoto to take a picture

Change-Id: I049e6cac42d4f30dcd9110828cce7af0bc74e7af
- needed to use raspistill and also needed for gphoto live preview

Change-Id: I13927db714833c90c2a26b1a3db0dc6f1a42baf3
Change-Id: Ifa23bc5eb80d47361a34e04b808a9e3a50807f99
@andi34 andi34 force-pushed the feature/gphoto-preview2 branch 4 times, most recently from 6176989 to 00a4d2c Compare November 16, 2020 19:07
Change-Id: I93b3d03f4203932aa98b0dae0037446dc26f6a17
Change-Id: I6a81e6950faf2367c86af2c97204247470df4b8b
@andi34 andi34 merged commit bb9996d into dev Nov 17, 2020
@andi34 andi34 deleted the feature/gphoto-preview2 branch November 17, 2020 19:41
andi34 referenced this pull request in couz74/photobooth Nov 17, 2020
Add Preview From Photo
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview from gphoto
2 participants